<!doctype html>
<html lang="en" class="fixed">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <title>学员列表</title>
    <!-- <link type="text/css" rel="stylesheet" href="../../topjui/plugins/layui/css/layui.css"> -->
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/layui/css/layui.css')) ?>" media="all">
    <link rel="stylesheet" type="text/css"
          href="<?php xcho(loadSource('/assets/plugins/bootstrap/css/bootstrap.min.css')) ?>">
    <link rel="stylesheet" type="text/css"
          href="<?php xcho(loadSource('/assets/plugins/bootstrap/css/bootstrap-datetimepicker.min.css')) ?>">
    <link rel="stylesheet" type="text/css"
          href="<?php xcho(loadSource('/assets/plugins/bootstrap/css/build_standalone.css')) ?>">
    <link rel="stylesheet" type="text/css" href="<?php xcho(loadSource('/assets/plugins/bootstrap/css/build.css')) ?>">
    <!-- TopJUI框架样式 -->
    <link type="text/css" href="<?php xcho(loadSource('/assets/css/topjui.core.min.css')) ?>" rel="stylesheet">
    <link type="text/css" href="<?php xcho(loadSource('/assets/themes/default/topjui.purplelight.css')) ?>" rel="stylesheet" id="dynamicTheme"/>
    <!-- FontAwesome字体图标 -->
    <link type="text/css" href="<?php xcho(loadSource('/assets/plugins/font-awesome/css/font-awesome.min.css')) ?>" rel="stylesheet"/>
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/ztree/css/zTreeStyle/zTreeStyle.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/css/new_main.css')) ?>">
</head>
<body><?php include_once TPL_PATH . 'public/nav.phtml'; ?>
<?php include_once TPL_PATH . 'public/nav.phtml'; ?>
<div class="">
    <div >
        <form action="<?php xcho(url('/student/student/index')) ?>" method="POST" accept-charset="utf-8"
              enctype="multipart/form-data" id="listAll">
            <div class="class-box">
                <div class="main-title">
                    <div class="layui-tab row" lay-filter="config" lay-allowClose="true">
                        <div class="layui-tab-title">
                            <input type="hidden" id="view_id" name="view_id" value="">
                                <ul class="col-md-8" style="display: inline-block;">
                                    <?php if(!empty($aView)) {?>
                                        <?php foreach ($aView as $aTmp) {?>
                                            <li class="layui-this" lay-id="<?php xcho($aTmp['pk'])?>" ><?php xcho($aTmp['cfg_name'])?></li>
                                        <?php }?>
                                    <?php }?>
                                </ul>
                                <div class="input-group col-md-4">
                                    <input type="text" class="form-control" placeholder="可搜索学员、联系手机" id="keyword"
                                       name="keyword" value="<?php xcho($search['keyword']) ?>">
                                    <span class="input-group-btn">
                                        <input type="submit" class="btn btn-primary edit" value="搜索" />
                                    </span>
                                </div>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-xs-6 col-sm-3 form-container">
                            <div>
                                <label>意向状态：</label>
                                <div class="checkbox">
                                    <?php foreach ($intention as $ik => $iv) { ?>
                                        <label class="checkbox-inline">
                                            <input type="checkbox" title="checkbox_intention"
                                                   name="intention[]" <?php if (!empty($search['intention'])) {
                                                foreach ($search['intention'] as $in) {
                                                    if ($in == $iv['dict_value']) { ?> checked="checked" <?php }
                                                }
                                            } ?>
                                                   value="<?php xcho($iv['dict_value']) ?>"></input><?php xcho($iv['cn_name']) ?>
                                        </label>
                                    <?php } ?>
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-6 col-sm-3 form-container form-inline">
                            <div class="form-group">
                                <label>查看范围：</label>
                                <input style="    width: 110px;height: 34px;border: none;font-size: 12px;border: 1px #ccc solid;text-indent: 6px;"
                                       results="s" class="form-control group-picker" id="scale_name" name="scale_name"
                                       type="search" value="<?php xcho($search['scale_name']) ?>"
                                       url="<?php xcho($sSearchRange) ?>">
                                <input results="s" id="scale_type" name="scale_type" type="hidden"
                                       value="<?php xcho($search['scale_type']) ?>">
                                <input results="s" id="scale_id" name="scale_id" type="hidden"
                                       value="<?php xcho($search['scale_id']) ?>">
                            </div>
                            <div class="form-group">
                                <label>修改日期：</label>
                                <select name="datetp" class="form-control">
                                    <option value="">全部</option>
                                    <?php foreach ($dateType as $dk => $dV) { ?>
                                        <option value="<?php xcho($dV['dict_value']) ?>" <?php if ($search['datetp'] == $dV['dict_value']) { ?> selected="selected"<?php } ?> > <?php xcho($dV['cn_name']) ?></option>
                                    <?php } ?>
                                </select>
                                <input size="16"
                                       type="text"  value="<?php xcho($search['begin_edit_time']) ?>"
                                       name="begin_edit_time" class="form-control begin_edit_time"
                                       placeholder="yy-mm-dd">

                                <input size="16" type="text"  value="<?php xcho($search['end_edit_time']) ?>" name="end_edit_time" class="form-control end_edit_time" placeholder="yy-mm-dd">
                            </div>
                            <div class="form-group">
                                <label>创建日期：</label>
                                <select name="add_time" class="form-control">
                                    <option value="">全部</option>
                                    <?php foreach ($dateType as $ak => $aV) { ?>
                                        <option value="<?php xcho($aV['dict_value']) ?>" <?php if ($search['add_time'] == $aV['dict_value']) { ?> selected="selected"<?php } ?> > <?php xcho($aV['cn_name']) ?></option>
                                    <?php } ?>
                                </select>
                                <input size="26" type="text"  value="<?php xcho($search['begin_add_time']) ?>" name="begin_add_time" class="form-control begin_add_time" placeholder="yy-mm-dd">
                                <input size="26" type="text"  value="<?php xcho($search['end_add_time']) ?>" name="end_add_time" class="form-control end_add_time" placeholder="yy-mm-dd">
                            </div>
                        </div>
                        <div class="col-xs-6 col-sm-3 form-container form-inline">
                            <div class="form-group">
                                <label>联系结果：</label>
                                <select name="contact_result" class="form-control">
                                    <option value="">全部</option>
                                    <?php foreach ($contact_result as $resu) { ?>
                                        <option value="<?php xcho($resu['dict_value']) ?>" <?php if ($search['contact_result'] == $resu['dict_value']) { ?>  selected="selected" <?php } ?> > <?php xcho($resu['cn_name']) ?></option>
                                    <?php } ?>
                                </select>
                            </div>

                            <div >
                                <?php if(!empty($channel)){ ?>
                                <a href="#" id="toggle">渠道展开</a>
                                <div id="content" style="display: none;">
                                <label>渠道：</label>
                                <label>全选：<input type="checkbox" id="channelAll"></label>
                                <div class="checkbox_channel">
                                    <?php foreach ($channel as  $cV) { ?>
                                        <label class="checkbox-inline">
                                            <input type="checkbox" title="checkbox_channel"
                                                   name="channel_id[]" <?php if (!empty($search['channel_id'])) {
                                                foreach ($search['channel_id'] as $in) {
                                                    if ($in == $cV['id']) { ?> checked="checked" <?php }
                                                }
                                            } ?>
                                                   value="<?php xcho($cV['id']) ?>"></input><?php xcho($cV['cn_name']) ?>
                                        </label>
                                    <?php } ?>
                                </div>
                                </div>
                                <?php } ?>
                            </div>


                            <div class="form-group">
                                <label>联系：</label>
                                <select name="is_follow" id="" class="form-control">
                                    <option value="all" <?php if ($search['is_follow'] == 'all') { ?> selected="selected" <?php } ?> >
                                        全部
                                    </option>
                                    <option value="yes" <?php if ($search['is_follow'] == 'yes') { ?> selected="selected" <?php } ?>>
                                        已联系
                                    </option>
                                    <option value="no" <?php if ($search['is_follow'] == 'no') { ?> selected="selected" <?php } ?>>
                                        未联系
                                    </option>
                                </select>
                            </div>
                            <div class="form-group">
                                <label>最新跟踪：</label>
                                <select name="last_follow_id" class="form-control">
                                    <option value="">全部</option>
                                    <?php foreach ($dateType as $fV) { ?>
                                        <option value="<?php xcho($fV['dict_value']) ?>" <?php if ($search['last_follow_id'] == $fV['dict_value']) { ?> selected="selected"<?php } ?> > <?php xcho($fV['cn_name']) ?></option>
                                    <?php } ?>
                                </select>
                                <input size="16" type="text"  value="<?php xcho($search['begin_last_follow_time']) ?>" name="begin_last_follow_time" class="form-control begin_last_follow_time" placeholder="yy-mm-dd">
                                <input size="16" type="text"  value="<?php xcho($search['end_last_follow_time']) ?>" name="end_last_follow_time" class="form-control end_last_follow_time"
                                       placeholder="yy-mm-dd">
                            </div>
                        </div>
                        <input type="text" name="orderby" value="<?php xcho($sOrderBy) ?>" style="display: none;">
                        <div class="col-xs-6 col-sm-3 form-container form-inline">
                            <div class="form-group">
                                <label>下次联系：</label>
                                <select name="next_contact_time" class="form-control">
                                    <option value="">全部</option>
                                    <?php foreach ($dateType as $nV) { ?>
                                        <option value="<?php xcho($nV['dict_value']) ?>" <?php if ($search['next_contact_time'] == $nV['dict_value']) { ?> selected="selected"<?php } ?> > <?php xcho($nV['cn_name']) ?></option>
                                    <?php } ?>
                                </select>
                                <input size="16"
                                       type="text"  value="<?php xcho($search['begin_next_contact_time']) ?>" name="begin_next_contact_time" class="form-control begin_next_contact_time"
                                       placeholder="yy-mm-dd">
                                <input size="16"
                                       type="text" value="<?php xcho($search['end_next_contact_time']) ?>" name="end_next_contact_time" class="form-control end_next_contact_time"
                                       placeholder="yy-mm-dd">
                                <input type="submit" class="btn btn-primary edit" value="搜索" />
                            </div>
                        </div>
                        <div class="btns-group">
                            <a href="javascript:;" class="btn btn-white" id="save_config">保存设置</a>
                            <a href="javascript:;" class="btn btn-primary" id="save_recover">恢复默认</a>
                        </div>
                    </div>
                </div>

            </div>
            <div class="class-box">
                <div class="class-box-head">
                    <div class="class-box-title">
                        <h3>学生列表</h3>
                        <div class="class-box-tools">
                            <?php if (!empty($aActions['add'])) { ?>
                                <a href="<?php xcho($addstudent)?>"><span class="btn btn-primary">添加</span></a>
                            <?php } ?>
                        </div>
                    </div>
                    <div class="from-top row">
                        <div class="from-top-left col-md-5">
                            <ul>
                                <?php if (!empty($aActions['edit_tmk'])) { ?>
                                    <li>
                                        <button type="button" class="btn btn-primary" id="tmk">分配TMK</button>
                                    </li>
                                <?php } ?>
                                <?php if (!empty($aActions['edit_cc'])) { ?>
                                    <li>
                                        <button type="button" id="cc" class="btn btn-primary">分配CC</button>
                                    </li>
                                <?php } ?>
                                <li class="dropdown">
                                    <button type="button" class="btn btn-warning dropdown-toggle"
                                            data-toggle="dropdown" href="#" role="button" aria-haspopup="true"
                                            aria-expanded="false">更多操作 <span class="caret"></span></button>
                                    <ul class="dropdown-menu">
                                        <?php if (!empty($aActions['edits'])) { ?>
                                            <li><a href="#" id="updates">批量修改</a></li>
                                        <?php } ?>
                                        <?php if (!empty($aActions['dels'])) { ?>
                                            <li><a href="#" id="dels" class="delete">批量删除</a></li>
                                        <?php } ?>
                                        <?php if (!empty($aActions['pool'])) { ?>
                                            <li><a href="#" id="pool">放入藏金阁</a></li>
                                        <?php } ?>
                                            <li><a href="<?php xcho(url('/sms/sendsms/index')) ?>" >批量发送短信</a></li>
                                    </ul>
                                </li>

                            </ul>
                        </div>
                        <div class="from-top-right col-md-7">
                            <ul class="nav navbar-nav navbar-right nav-margin">
                                <li><input type="file" name="stu_import" class="btn btn-primary btn_import"
                                           id="stu_import"/></li>
                                <li><span class="btn btn-primary daoru">导入</span></li>
                                <?php if (!empty($aActions['excel'])) { ?>
                                <li><span class="btn btn-default test_stu_export">导出</span></li>
                                <?php } ?>
                            </ul>
                        </div>
                    </div>
                </div>

                <form method="post" action="<?php xcho(url('/student/student/index')) ?>">
                    <div class="row pagination-wrap">
                        <div class="col-sm-6">

                            <div class="pagination-group col-sm-12">
                                <input class="form-control" type="number" min="1" max="<?php xcho($maxPage) ?>"
                                   name="pagelist" placeholder="请输入页码" value="<?php xcho($nowPage) ?>"/>
                                <input class="btn btn-primary" type="submit" value="确定"/>
                                <span>共搜索到<?php xcho($totalNum) ?>条记录</span>
                            </div>
                        </div>
                        <div class="col-sm-6">
                            <ul class="pagination">
                                <?php xchoHtml($page->render()) ?>
                            </ul>
                        </div>
                    </div>
                </form>
                
                <div class="class-box-body">
                    <table class="layui-form table table-bordered table-hover table table-bordered table-striped table-fixed">
                        <thead>
                        <tr>
                            <th>
                                <div id="checkAll"><input lay-filter="allChoose" type="checkbox" lay-skin="primary" name="checkAll"></div>
                            </th>
                            <th>名称</th>
                            <th>联系手机</th>
                            <th>意向状态</th>
                            <th style="cursor: pointer;">
                                <a style="position: relative;"  href="javascript:;">
                                    最新跟踪时间
                                    <span style="position: absolute; top:-6px" ><a href="<?php xcho($order_by_field['last_follow_time_asc']) ?>"><i class="upOrder glyphicon glyphicon-triangle-top" style="display:"></i></a>
                                           <a href="<?php xcho($order_by_field['last_follow_time_desc']) ?>"><i class="dropOrder glyphicon glyphicon-triangle-bottom"style="display:
                                       "></i></a>
                                    </span>
                            </th>
                            <th width="150px">最新跟踪记录</th>
                            <th>最新追踪结果</th>
                            <th style="cursor: pointer;">
                                <a style="position: relative;"  href="javascript:;">
                                    TMK负责人
                                    <span style="position: absolute; top:-6px" ><a href="<?php xcho($order_by_field['tmk_id_asc']) ?>"><i class="upOrder glyphicon glyphicon-triangle-top" style="display:"></i></a>
                                           <a href="<?php xcho($order_by_field['tmk_id_desc']) ?>"><i class="dropOrder glyphicon glyphicon-triangle-bottom"style="display:
                                       "></i></a>
                                    </span>
                            </th>
                            <th style="cursor: pointer;">
                                <a style="position: relative;"  href="javascript:;">
                                    CC负责人
                                    <span style="position: absolute; top:-6px" ><a href="<?php xcho($order_by_field['cc_id_asc']) ?>"><i class="upOrder glyphicon glyphicon-triangle-top" style="display:"></i></a>
                                           <a href="<?php xcho($order_by_field['cc_id_desc']) ?>"><i class="dropOrder glyphicon glyphicon-triangle-bottom"style="display:
                                       "></i></a>
                                    </span>
                            </th>
                            <th style="cursor: pointer;">
                                <a style="position: relative;"  href="javascript:;">
                                    渠道来源
                                    <span style="position: absolute; top:-6px" ><a href="<?php xcho($order_by_field['channel_id_asc']) ?>"><i class="upOrder glyphicon glyphicon-triangle-top" style="display:"></i></a>
                                           <a href="<?php xcho($order_by_field['channel_id_desc']) ?>"><i class="dropOrder glyphicon glyphicon-triangle-bottom"style="display:
                                       "></i></a>
                                    </span>
                            </th>
                            <th style="cursor: pointer;">
                                <a style="position: relative;"  href="javascript:;">
                                   下次联系时间
                                    <span style="position: absolute; top:-6px" ><a href="<?php xcho($order_by_field['next_contact_time_asc']) ?>"><i class="upOrder glyphicon glyphicon-triangle-top" style="display:"></i></a>
                                           <a href="<?php xcho($order_by_field['next_contact_time_desc']) ?>"><i class="dropOrder glyphicon glyphicon-triangle-bottom"style="display:
                                       "></i></a>
                                    </span>
                            </th>
                            <th style="cursor: pointer;">
                                <a style="position: relative;"  href="javascript:;">
                                    创建时间
                                    <span style="position: absolute; top:-6px" ><a href="<?php xcho($order_by_field['add_time_asc']) ?>"><i class="upOrder glyphicon glyphicon-triangle-top" style="display:"></i></a>
                                           <a href="<?php xcho($order_by_field['add_time_desc']) ?>"><i class="dropOrder glyphicon glyphicon-triangle-bottom"style="display:
                                       "></i></a>
                                    </span>
                            </th>
                            <th style="cursor: pointer;">
                                <a style="position: relative;"  href="javascript:;">
                                    修改时间
                                    <span style="position: absolute; top:-6px" ><a href="<?php xcho($order_by_field['edit_time_asc']) ?>"><i class="upOrder glyphicon glyphicon-triangle-top" style="display:"></i></a>
                                           <a href="<?php xcho($order_by_field['edit_time_desc']) ?>"><i class="dropOrder glyphicon glyphicon-triangle-bottom"style="display:
                                       "></i></a>
                                    </span>
                            </th>
                            <th width="120px">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php foreach ($list as $vo) { ?>
                            <tr>
                                <td>
                                    <input lay-filter="itemChoose" value="<?php xcho($vo['id']) ?>" type="checkbox"
                                           name="ck" lay-skin="primary">
                                </td>
                                <td>
                                    <a href="/student/student/studentinfo?offset=<?php xcho($vo['offset'])?>&student_id=<?php xcho($vo['id'].$paramsUrl) ?>" target="_blank"><?php xcho($vo['sname']) ?></a>
                                </td>
                                <td><?php xcho($vo['cellphone']) ?></td>
                                <td><?php xcho($vo['intention_name']) ?></td>
                                <td><?php xcho($vo['new_add_time']) ?></td>
                                <td><?php xcho($vo['new_follow_remark']) ?></td>
                                <td><?php xcho($vo['new_contact_result_name']) ?></td>
                                <td><?php xcho($vo['tmk_name']) ?></td>
                                <td><?php xcho($vo['cc_name']) ?></td>
                                <td><?php xcho($vo['channel_cn_name']) ?></td>
                                <td><?php xcho($vo['next_contact_time']) ?></td>
                                <td><?php xcho($vo['add_time_name']) ?></td>
                                <td><?php xcho($vo['edit_time_name']) ?></td>
                                <td class="tdrow">
                                    <?php if (!empty($aActions['edit'])) { ?>
                                        <button data-cn_id="<?php xcho($vo['id']) ?>" type="button"
                                                class="btn btn-primary edit"
                                                user_id="<?php xcho($vo['id']) ?>"><a
                                                    style="display: block;color: #ffffff"
                                                    href="<?php xcho($editstudent) ?>?student_id=<?php xcho($vo['id']) ?>">编辑</a>
                                        </button>
                                    <?php } ?>
                                    <?php if (!empty($aActions['del'])) { ?>
                                        <button data-cn_id="<?php xcho($vo['id']) ?>" type="button"
                                                class="btn btn-sub delete">删除
                                        </button>
                                    <?php } ?>

                                </td>
                            </tr>
                        <?php } ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </form>
    </div>
</div>
<div class="modal fade" id="tmk-modal" tabindex="-1" role="dialog" aria-labelledby="modal-primary-label"
     style="z-index:9999;display: none;">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header state modal-primary">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">×</span></button>
                <h4 class="modal-title" id="modal-primary-label"><i class="fa fa-user"></i>选择负责人</h4>
            </div>
            <div class="form-group">
                <input class="form-control" id="tmklistinput" type="text">
            </div>
            <div class="modal-body ztree" id="tmklist">

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" id="suretmk" data-dismiss="modal">　保存</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="cc-modal" tabindex="-1" role="dialog" aria-labelledby="modal-primary-label"
     style="z-index:9999;display: none;">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header state modal-primary">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">×</span></button>
                <h4 class="modal-title" id="modal-primary-label"><i class="fa fa-user"></i>选择负责人</h4>
            </div>
            <div class="form-group">
                <input class="form-control" id="cclistinput" type="text">
            </div>
            <div class="modal-body ztree" id="cclist">

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" id="surecc" data-dismiss="modal">　保存</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>

<div id="modalbox"></div>
<div class="modal fade" id="info-modal-group" tabindex="-1" role="dialog" aria-labelledby="modal-info-label">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header state modal-info">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="modal-info-label"><i class="fa fa-info"></i></h4>
            </div>
            <div class="modal-body" style="min-height: 150px;">
                <div class="form-group">
                    <input class="form-control" id="treeDemoinput" type="text">
                </div>
                <ul id="treeDemo" class="ztree">
                </ul>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-info" id="sureGroup" data-dismiss="modal">确定</button>
                <button type="button" class="btn btn-default" id="returnGroup" data-dismiss="modal">返回</button>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="config-modal" tabindex="-1" role="dialog" aria-labelledby="modal-primary-label"
     style="z-index:9999;display: none;">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header state modal-primary">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">×</span></button>
                <h4 class="modal-title" id="modal-primary-label"><i class="fa fa-user"></i>自定义快捷视图</h4>
            </div>
            <div class="modal-body layui-form" style="min-height: 150px;">
                <?php if(isset($aActions['config']) && $aActions['config'] == 'Y') {?>
                    <div class="layui-form-item">
                        <label class="layui-form-label">是否公用</label>
                        <div class="layui-input-block">
                            <select id="is_public" name="is_public" lay-verify="required">
                                <?php foreach ($aConfirm as $aTmp) { ?>
                                    <option value="<?php xcho($aTmp['dict_value']) ?>"><?php xcho($aTmp['cn_name']) ?></option>
                                <?php } ?>
                            </select>
                        </div>
                    </div>
                <?php }?>
                <div class="layui-form-item">
                    <label class="layui-form-label">快捷视图标题</label>
                    <div class="layui-input-block">
                        <input type="text" id="cfg_name" name="cfg_name" required
                               lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                        <input type="hidden" id="module" name="module" value="<?php xcho($sControllerModule)?>">
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <span type="button" class="btn btn-primary" id="sureConfig" data-dismiss="modal" url="<?php xcho($saveConfig)?>">保存</span>
                <span type="button" class="btn btn-default" data-dismiss="modal">关闭</span>
            </div>
        </div>
    </div>
</div>
<div id="updatebox" style="display: none">
    <select name="quickedit_field" class="small" style="width: 100%" onchange="quick_edit_fieldchange(this)">
        <option>请选择</option>
        <option value="sname" relvalue="1">学员姓名</option>
        <option value="cellphone" relvalue="1">联系手机</option>
        <option value="telephone" relvalue="15">家庭座机</option>
        <option value="sex" relvalue="1">性别</option>
        <option value="age" relvalue="1">年龄</option>
        <option value="wechat" relvalue="1">微信</option>
        <option value="qq" relvalue="1">QQ</option>
        <option value="email" relvalue="1">邮箱</option>
        <option value="channel_id" relvalue="15">渠道来源</option>
        <option value="province" relvalue="11">省</option>
        <option value="city" relvalue="5">市</option>
        <option value="county" relvalue="1">区县</option>
        <option value="home_address" relvalue="1">家庭地址</option>
        <option value="admission_time" relvalue="15">入学时间</option>
        <option value="school" relvalue="15">当前学校</option>
        <option value="grade" relvalue="5">年级</option>
        <option value="intention" relvalue="1">意向状态</option>
        <option value="is_test" relvalue="1021">是否测试</option>
        <option value="is_treasure" relvalue="1022">是否丢入藏经阁</option>
        <option value="creator_id" relvalue="86">创建人id</option>
        <option value="twx_id" relvalue="1033">天王星学员id</option>
        <option value="gw_id" relvalue="1">官网学员id</option>
        <option value="gw_password" relvalue="1">官网学员密码</option>
        <option value="tmk_id" relvalue="15">TMKID</option>
        <option value="cc_id" relvalue="15">CCID</option>
    </select>
    <div class="up_area" style="width: 100%;margin-top: 20px;">
        <div id="quickedit_field0" style="display: none;">&nbsp;</div>
        <div id="quickedit_field_sname" uitype="1" style="display: none;">
            <input type="text" tabindex="1" name="quickedit_value_sname" id="sname" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_cellphone" uitype="1" style="display: none;">
            <input type="text" tabindex="12" name="quickedit_value_cellphone" id="cellphone" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_telephone" uitype="1" style="display: none;">
            <input type="text" tabindex="12" name="quickedit_value_telephone" id="telephone" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_sex" uitype="15" style="display: none;">
            <select name="quickedit_value_sex" id="sex" tabindex="511111" class="small">
                <option value="无">
                    无
                </option>
                <option value="male">
                    男
                </option>
                <option value="female">
                    女
                </option>
            </select>
        </div>
        <div id="quickedit_field_age" uitype="1" style="display: none;">
            <input type="text" tabindex="12" name="quickedit_value_age" id="age" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_wechat" uitype="1" style="display: none;">
            <input type="text" tabindex="12" name="quickedit_value_wechat" id="wechat" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_qq" uitype="1" style="display: none;">
            <input type="text" tabindex="12" name="quickedit_value_qq" id="qq" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_email" uitype="1" style="display: none;">
            <input type="text" tabindex="12" name="quickedit_value_email" id="email" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_channel_id" uitype="15" style="display: none;">
            <!-- uitype 111 added for noneditable existing picklist values - ahmed -->
            <select name="quickedit_value_channel_id" id="channel_id" tabindex="211111" class="small">
                <?php foreach ($channel as $cV) { ?>
                    <option value="<?php xcho($cV['id']) ?>" <?php if ($search['channel_id'] == $cV['id']) { ?>  selected="selected" <?php } ?> > <?php xcho($cV['cn_name']) ?></option>
                <?php } ?>
            </select>
        </div>
        <div id="quickedit_field_province" uitype="1" style="display: none;">
            <input type="text" tabindex="13" name="quickedit_value_province" id="province" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_city" uitype="1" style="display: none;">
            <input type="text" tabindex="3" name="quickedit_value_city" id="city" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_county" uitype="1" style="display: none;">
            <input type="text" tabindex="14" name="quickedit_value_county" id="county" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_home_address" uitype="1" style="display: none;">
            <input type="text" tabindex="4" name="quickedit_value_home_address" id="home_address" value=""
                   class="detailedViewTextBox">


        </div>
        <div id="quickedit_field_admission_time" uitype="1" style="display: none;">
            <input type="text" tabindex="15" name="quickedit_value_admission_time" id="admission_time" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_school" uitype="11" style="display: none;">
            <input type="text" tabindex="16" name="quickedit_value_school" id="school" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_grade" uitype="5" style="display: none;">

            <input name="quickedit_value_grade" tabindex="6" id="jscal_field_grade" type="text"
                   style="border:1px solid #bababa;" size="11" maxlength="10" value="">
            <i class="icon-calendar pure-icon-bu crm-bu-style" onclick="displayCalendar('jscal_field_cf_865',this);"
               style="width:50px;height:50px;cursor:pointer;font-size:14px">
            </i>
        </div>
        <div id="quickedit_field_intention" uitype="1" style="display: none;">
            <input type="text" tabindex="17" name="quickedit_value_intention" id="intention" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_is_test" uitype="1" style="display: none;">
            <input type="text" tabindex="7" name="quickedit_value_is_test" id="is_test" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_is_treasure" uitype="15" style="display: none;">
            <!-- uitype 111 added for noneditable existing picklist values - ahmed -->
            <select name="quickedit_value_is_treasure" id="is_treasure" tabindex="1811111" class="small">
                <option value="no">
                    否
                </option>
                <option value="yes">
                    是
                </option>
            </select>
        </div>
        <div id="quickedit_field_creator_id" uitype="5" style="display: none;">
            <input name="quickedit_value_creator_id" tabindex="19" id="creator_id" type="text">
        </div>
        <div id="quickedit_field_twx_id" uitype="5" style="display: none;">
            <input name="quickedit_value_twx_id" tabindex="19" id="twx_id" type="text">
        </div>
        <div id="quickedit_field_gw_id" uitype="5" style="display: none;">
            <input name="quickedit_value_gw_id" tabindex="19" id="gw_id" type="text">
        </div>
        <div id="quickedit_field_tmk_id" uitype="5" style="display: none;">
            <input name="quickedit_value_tmk_id" tabindex="19" id="tmk_id" type="text">
        </div>
        <div id="quickedit_field_cc_id" uitype="5" style="display: none;">
            <input name="quickedit_value_cc_id" tabindex="19" id="cc_id" type="text">
        </div>
    </div>
</div>
<input type="hidden" name="del" value="<?php xcho($del) ?>"/>
<input type="hidden" name="dels" value="<?php xcho($dels) ?>"/>
<input type="hidden" name="groupList" value="<?php xcho($groupList) ?>">
<input type="hidden" name="tmklist" value="<?php xcho($tmkList) ?>">
<input type="hidden" name="cclist" value="<?php xcho($ccList) ?>">
<input type="hidden" name="isTreasure" value="<?php xcho($isTreasure) ?>">
<input type="hidden" name="editTMK" value="<?php xcho($editTMK) ?>">
<input type="hidden" name="editCC" value="<?php xcho($editCC) ?>">
<input type="hidden" name="add_student" value="<?php xcho($addstudent) ?>"/>
<input type="hidden" name="edit_student" value="<?php xcho($editstudent) ?>"/>
<input type="hidden" name="batch_student" value="<?php xcho($batchStudent) ?>"/>
<input type="hidden" name="stuExport" value="<?php xcho($stuExport) ?>"/>
<input type="hidden" name="stuRepaetExport" value="<?php xcho($stuRepaetExport) ?>"/>
<input type="hidden" name="stuImport" value="<?php xcho($stuImport) ?>"/>
<script src="<?php xcho(loadSource('/assets/plugins/jquery/jquery.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/layui/layui.all.js')) ?>" charset="utf-8"></script>
<script src="<?php xcho(loadSource('/assets/plugins/bootstrap/js/bootstrap.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/bootstrap/js/bootstrap-datetimepicker.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/bootstrap/js/bootstrap-datetimepicker.fr.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/bootstrap/js/bootstrap-datetimepicker.zh-CN.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets//plugins/ztree/js/jquery.ztree.core.js')) ?>"></script>
<script type="text/javascript"
        src="<?php xcho(loadSource('/assets//plugins/ztree/js/jquery.ztree.excheck.js')) ?>"></script>
<script type="text/javascript"
        src="<?php xcho(loadSource('/assets//plugins/ztree/js/jquery.ztree.exedit.js')) ?>"></script>
<script>

    $(function(){


        $("#toggle").click(function() {
            $(this).text($("#content").is(":hidden") ? "渠道收起" : "渠道展开");
            $("#content").slideToggle();
        });

        $("#top").click(function() {
            $("html,body").animate({scrollTop:0}, 500);
        });
        layui.use(['layer', 'form'], function () {
            var element = layui.element;
            //监听Tab切换，以改变地址hash值
            element.on('tab(config)', function () {
                $("#view_id").val(this.getAttribute('lay-id'));
                var view_all = $("#view_id").val();
                if(view_all == "nomal"){
                    $("#listAll").find('input[type=text],select,input[type=checkbox]').each(function(){
                      $(this).val('');
                    });
                }
                $("input[type='submit']").click();
            });
        });

        $("#channelAll").click(function(){
            var ischecked = $(this).is(':checked');
            var child = $(".checkbox_channel").find('input[type=checkbox]');
            child.each(function(index, item){
                item.checked = ischecked;
            });
        });
    })
    $(".layui-tab-close").on('click',function () {
        $.ajax({
            url: "<?php xcho($sDelView)?>",
            data: {
                id: $(this).parent().attr('lay-id')
            },
            type: 'post',
            dataType: 'json',
            success: function (data) {
                if (data.success == 1) {
                    layer.alert("删除成功!")
                } else {
                    alert(data.msg);
                }
            },
            complete: function () {
                location.reload();
            },
            error: function () {

            }
        });
    });

    //显示保存快捷视图
    $("#save_config").on("click", function () {

        $('#config-modal').modal({
            keyboard: false,
            backdrop: false
        });
        $("#select-picker").focus(function () {
            $('#config-modal').modal({
                keyboard: false,
                backdrop: false
            });
        });
    })

    //保存视图
    $("#sureConfig").on("click", function () {
        var ids = [];
        $('.checkbox').find("input[title='checkbox_intention']:checked").each(function () {
            ids.push($(this).val());
        });
        var channelids=[];
        $('.checkbox_channel').find("input[title='checkbox_channel']:checked").each(function () {
            channelids.push($(this).val());
        });

        var aArrData = new Array();
        aArrData = {
            'is_public':$("#is_public").val(),
            'cfg_name':$("#cfg_name").val(),
            'module':$("#module").val(),
            'cfg_value':{
                'scale_name':$("#scale_name").val(),
                'scale_type':$("#scale_type").val(),
                'scale_id':$("#scale_id").val(),
                'intention':ids,
                'datetp':$("[name='datetp']").val(),
                'add_time':$("[name='add_time']").val(),
                'channel_id':channelids,
                'is_follow':$("[name='is_follow']").val(),
                'last_follow_id':$("[name='last_follow_id']").val(),
                'next_contact_time':$("[name='next_contact_time']").val(),
                'keyword':$("[name='keyword']").val(),
                'contact_result':$("[name='contact_result']").val(),
            }
        };
        $.ajax({
            url: $("#sureConfig").attr('url'),
            type: 'post',
            data: aArrData,
            dataType: 'json',
            success: function (data) {
                console.log(data)
                if (data.success == 1) {
                    location.reload();
                } else {
                }
            },
            complete: function () {
            },
            error: function () {

            }
        });
    })

    //恢复默认视图
    $("#save_recover").on("click", function () {
        var aArrData = new Array();

        $.ajax({
            url: "<?php xcho($sRestoreView)?>",
            type: 'post',
            data: {
                'module':$("#module").val(),
            },
            dataType: 'json',
            success: function (data) {
                if (data.success == 1) {
                    location.reload();
                } else {
                }
            },
            complete: function () {
            },
            error: function () {

            }
        });
    })
    var select_option, select_element;
    function quick_edit_fieldchange(element) {

        var e = "#quickedit_field_" + element.value;
        $("div[id*='quickedit_field_']").css("display", "none");
        $("#LAY_layuipro").find(e).fadeIn();
        select_option = element.value;
        select_element = e
    }

    var layer = layui.layer
        , form = layui.form, laydate = layui.laydate;
    //全选
    layui.form.on('checkbox(allChoose)', function(data){
        var child = $(data.elem).parents('table').find('tbody input[type="checkbox"]');
        child.each(function(index, item){
            item.checked = data.elem.checked;
        });
        form.render('checkbox');
    });
    //日历
    $(".begin_edit_time").datetimepicker({
        format: "yyyy-mm-dd",
        todayHighlight: true,
        autoclose: true,
        language: 'zh-CN',
        startView: 2,
        minView: 2,
        maxView: 2
    });
    $(".end_edit_time").datetimepicker({
        format: "yyyy-mm-dd",
        todayHighlight: true,
        autoclose: true,
        language: 'zh-CN',
        startView: 2,
        minView: 2,
        maxView: 2
    });
    $(".begin_add_time").datetimepicker({
        format: "yyyy-mm-dd",
        todayHighlight: true,
        autoclose: true,
        language: 'zh-CN',
        startView: 2,
        minView: 2,
        maxView: 2
    });
    $(".end_add_time").datetimepicker({
        format: "yyyy-mm-dd",
        todayHighlight: true,
        autoclose: true,
        language: 'zh-CN',
        startView: 2,
        minView: 2,
        maxView: 2
    });
    $(".begin_last_follow_time").datetimepicker({
        format: "yyyy-mm-dd",
        todayHighlight: true,
        autoclose: true,
        language: 'zh-CN',
        startView: 2,
        minView: 2,
        maxView: 2
    });
    $(".end_last_follow_time").datetimepicker({
        format: "yyyy-mm-dd",
        todayHighlight: true,
        autoclose: true,
        language: 'zh-CN',
        startView: 2,
        minView: 2,
        maxView: 2
    });
    $(".begin_next_contact_time").datetimepicker({
        format: "yyyy-mm-dd",
        todayHighlight: true,
        autoclose: true,
        language: 'zh-CN',
        startView: 2,
        minView: 2,
        maxView: 2
    });
    $(".end_next_contact_time").datetimepicker({
        format: "yyyy-mm-dd",
        todayHighlight: true,
        autoclose: true,
        language: 'zh-CN',
        startView: 2,
        minView: 2,
        maxView: 2
    });
    $(".form-group>select").change(function () {
        var dataVal = $(this).val();
        var aDataInfo = getDates(dataVal);
        var sClassInfo = $(this).attr('name');
        if (sClassInfo == 'datetp') {
            $('.begin_edit_time').val(aDataInfo['sStartDate']);
            $('.end_edit_time').val(aDataInfo['sEndDate']);
        }
        if (sClassInfo == 'add_time') {
            $('.begin_add_time').val(aDataInfo['sStartDate']);
            $('.end_add_time').val(aDataInfo['sEndDate']);
        }
        if (sClassInfo == 'next_contact_time') {
            $('.begin_next_contact_time').val(aDataInfo['sStartDate']);
            $('.end_next_contact_time').val(aDataInfo['sEndDate']);
        }
        if (sClassInfo == 'last_follow_id') {
            $('.begin_last_follow_time').val(aDataInfo['sStartDate']);
            $('.end_last_follow_time').val(aDataInfo['sEndDate']);
        }

    });
    //        $(".form-group>select").change(function(){
    //            var dataVal = $(this).val();
    //            if(dataVal == 'define'){
    //                $(this).siblings("input").attr('disabled',false);
    //            }else{
    //                $(this).siblings("input").attr('disabled',true);
    //                $(this).siblings("input").val("");
    //                $(this).siblings("input").attr('placeholder','yy-mm-dd');
    //            }
    //        });

    $(".top_more").hover(function () {
        $(this).find("ul").show();
    }, function () {
        $(this).find("ul").hide();
    });
    $("#dels").on("click", function () {
        var ids = [];
        $('input[name="ck"]:checked').each(function () {
            ids.push($(this).val());
        });
        if (ids.length == 0) {
            layer.alert("至少选择一项");
        } else {
            $.ajax({
                url: $("input[name='dels']").val(),
                data: {
                    ids: ids
                },
                type: 'post',
                dataType: 'json',
                success: function (data) {
                    if (data.success == 1) {
                        layer.alert("删除成功！", function () {
                            location.reload();
                        });
                    } else {

                    }
                },
                complete: function () {
                },
                error: function () {

                }
            });
        }

    });
    $("#pool").on("click", function () {
        var ids = [];
        $('input[name="ck"]:checked').each(function () {
            ids.push($(this).val());
        });

        if (ids.length == 0) {
            layer.alert("至少选择一项");
        } else {
            $.ajax({
                url: $("input[name='isTreasure']").val(),
                data: {
                    ids: ids
                },
                type: 'post',
                dataType: 'json',
                success: function (data) {
                    if (data.success == 1) {
                        layer.alert("操作成功！", function () {
                            location.reload();
                        });
                    } else {

                    }
                },
                complete: function () {
                },
                error: function () {

                }
            });
        }

    });
    $("#updates").on("click", function () {
        var ids = [];
        $('input[name="ck"]:checked').each(function () {
            ids.push($(this).val());
        });
        if (ids.length == 0) {
            layer.alert("至少选择一项");
        } else {
            layer.open({
                type: 1
                , title: false //不显示标题栏
                , closeBtn: false
                , area: '300px;'
                , shade: 0.8
                , id: 'LAY_layuipro' //设定一个id，防止重复弹出
                , btn: ['保存', '取消']
                , moveType: 1 //拖拽模式，0或者1
                , content: '<div style="padding: 50px; line-height: 22px;  font-weight: 300;">' +
                $("#updatebox").html() +
                '</div>'
                , success: function (layero) {
                    var select_data = {};
                    var btn = layero.find('.layui-layer-btn');
                    btn.css('text-align', 'center');
                    btn.find('.layui-layer-btn0').on("click", function () {
                        var a = ".layui-layer-content #" + select_option;
                        select_data[select_option] = $(a).val()
                        $.ajax({
                            url: $("input[name='batch_student']").val(),
                            data: {
                                ids: ids,
                                data: select_data
                            },
                            type: 'post',
                            dataType: 'json',
                            success: function (data) {
                                if (data.success == 1) {
                                    layer.alert("修改成功！", function () {
                                        location.reload();
                                    });
                                } else {

                                }
                            },
                            complete: function () {
                            },
                            error: function () {

                            }
                        });
                    })
                }
            });
        }

    });
    $("#tmk").on("click", function () {
        var ids = [];
        $('input[name="ck"]:checked').each(function () {
            ids.push($(this).val());
        });
        if (ids.length == 0) {
            layer.alert("至少选择一项");
        } else {
            var modal = '<div class="modal fade" id="data-modal" tabindex="1" role="dialog" aria-labelledby="modal-info-label">' +
                ' <div class="modal-dialog" role="document">' +
                ' <div class="modal-content">' +
                '<div class="modal-header state modal-info">' +
                '<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>' +
                '</button>' +
                '<h4 class="modal-title" id="modal-info-label"><i class="fa fa-info"></i></h4>' +
                '</div>' +
                ' <div class="modal-body" style="min-height: 150px;">' +
                '<div class="col-xs-12">' +
                ' <label class="col-sm-3 control-label" style="line-height: 34px;text-align: right">TMK:</label>' +
                '<div class="col-sm-9">' +
                '<input class="form-control" data-tmk-id="" id="select-picker" name="select-picker" type="text" placeholder="TMK">' +
                '</div>' +
                '</div>' +
                '</div>' +
                '<div class="modal-footer">' +
                '<button type="button" class="btn btn-info" id="surepass" data-dismiss="modal">保存</button>' +
                '<button type="button" class="btn btn-default" id="returnGroup" data-dismiss="modal">返回</button>' +
                '</div>' +
                '</div>' +
                '</div>' +
                '</div>';
            $("#modalbox").html("").html(modal);
            $('#data-modal').modal({
                keyboard: false,
                backdrop: false
            });
            $("#select-picker").focus(function () {
                $('#tmk-modal').modal({
                    keyboard: false,
                    backdrop: false
                });
            });
            $("#suretmk").on("click", function () {
                var zTree = $.fn.zTree.getZTreeObj("tmklist"),
                    nodes = zTree.getSelectedNodes(),
                    treeNode = nodes[0];
                if (nodes.length == 0) {
                    alert("请先选择一个节点");
                    return;
                }
                $("#select-picker").val(treeNode.name).attr("data-tmk-id", treeNode.id);
            })
            $("#surepass").on("click", function () {
                $.ajax({
                    url: $("input[name='editTMK']").val(),
                    type: 'post',
                    data: {
                        student_ids: ids,
                        tmk_id: $("input[name='select-picker']").attr("data-tmk-id")
                    },
                    dataType: 'json',
                    success: function (data) {
                        if (data.success == 1) {
                            location.reload();
                        } else {
                        }
                    },
                    complete: function () {
                    },
                    error: function () {

                    }
                });
            })
        }
    })
    $("#cc").on("click", function () {
        var ids = [];
        $('input[name="ck"]:checked').each(function () {
            ids.push($(this).val());
        });
        if (ids.length == 0) {
            layer.alert("至少选择一项");
        } else {
            var modal = '<div class="modal fade" id="data-modal" tabindex="1" role="dialog" aria-labelledby="modal-info-label">' +
                ' <div class="modal-dialog" role="document">' +
                ' <div class="modal-content">' +
                '<div class="modal-header state modal-info">' +
                '<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>' +
                '</button>' +
                '<h4 class="modal-title" id="modal-info-label"><i class="fa fa-info"></i></h4>' +
                '</div>' +
                ' <div class="modal-body" style="min-height: 150px;">' +
                '<div class="col-xs-12">' +
                ' <label class="col-sm-3 control-label" style="line-height: 34px;text-align: right">CC:</label>' +
                '<div class="col-sm-9">' +
                '<input class="form-control" id="select-picker" name="select-picker" type="text" placeholder="CC">' +
                '</div>' +
                '</div>' +
                '</div>' +
                '<div class="modal-footer">' +
                '<button type="button" class="btn btn-info" id="savecc" data-dismiss="modal">保存</button>' +
                '<button type="button" class="btn btn-default" id="returncc" data-dismiss="modal">返回</button>' +
                '</div>' +
                '</div>' +
                '</div>' +
                '</div>';
            $("#modalbox").html("").html(modal);
            $('#data-modal').modal({
                keyboard: false,
                backdrop: false
            });
            $("#select-picker").focus(function () {
                $('#cc-modal').modal({
                    keyboard: false,
                    backdrop: false
                });
            });
            $("#surecc").on("click", function () {
                var zTree = $.fn.zTree.getZTreeObj("cclist"),
                    nodes = zTree.getSelectedNodes(),
                    treeNode = nodes[0];
                if (nodes.length == 0) {
                    alert("请先选择一个节点");
                    return;
                }
                $("#select-picker").val(treeNode.name).attr("data-cc-id", treeNode.id);
            })
            $("#savecc").on("click", function () {
                $.ajax({
                    url: $("input[name='editCC']").val(),
                    type: 'post',
                    data: {
                        student_ids: ids,
                        cc_id: $("input[name='select-picker']").attr("data-cc-id")
                    },
                    dataType: 'json',
                    success: function (data) {
                        if (data.success == 1) {
                            location.reload();
                        } else {
                        }
                    },
                    complete: function () {
                    },
                    error: function () {

                    }
                });
            })
        }
    })
    /*$("#add").on("click", function () {
        window.parent.addParentTab({href: $("input[name='add_student']").val(), title: '添加学员'})
    })*/
    $(".delete").on("click", function () {
        if (confirm("确定删除本条数据吗？")) {
            var cn_id = $(this).attr("data-cn_id");
            $.ajax({
                url: $("input[name='del']").val(),
                data: {
                    ids: cn_id
                },
                type: 'post',
                dataType: 'json',
                success: function (data) {
                    if (data.success == 1) {
                        layer.alert("删除成功!", {
                            skin: 'layui-layer-molv'
                        }, function () {
                            location.reload();
                        })
                    } else {
                        layer.alert(data.msg, {
                            skin: 'layui-layer-molv'
                        }, function () {
                            location.reload();
                        })
                    }
                },
                complete: function () {
                },
                error: function () {

                }
            });
        }
    })

    function getTmkListData() {
        var data_list;
        $.ajax({
            url: $("input[name='tmklist']").val(),
            type: 'post',
            async: false,
            dataType: 'json',
            success: function (data) {
                if (data.success == 1) {
                    try {
                        data_list = data.data_list;
                    } catch (err) {
                        console.log("Error name: " + err.name + "");
                        console.log("Error message: " + err.message);
                    }
                    finally {
                        console.log("object is null");
                    }

                } else {
                }
            },
            complete: function () {
            },
            error: function () {

            }
        });
        return data_list;
    }

    function getCcListData() {
        var data_list;
        $.ajax({
            url: $("input[name='cclist']").val(),
            type: 'post',
            async: false,
            dataType: 'json',
            success: function (data) {
                if (data.success == 1) {
                    try {
                        data_list = data.data_list;
                    } catch (err) {
                        console.log("Error name: " + err.name + "");
                        console.log("Error message: " + err.message);
                    }
                    finally {
                        console.log("object is null");
                    }
                } else {
                }
            },
            complete: function () {
            },
            error: function () {

            }
        });
        return data_list;
    }
    $(".group-picker").focus(function () {
        $('#info-modal-group').modal({
            keyboard: false,
            backdrop: false
        });
        $('#info-modal-group').on('shown.bs.modal', function (e) {
            // 关键代码，如没将modal设置为 block，则$modala_dialog.height() 为零
            $(this).css('display', 'block');
            $(this).find('.modal-dialog').css({
                'margin-top': "100px"
            });
        });
    });
    //查看范围
    var setting = {
        view: {
            selectedMulti: false
        },
        edit: {
            enable: false
        },
        data: {
            keep: {
                parent: true,
                leaf: true
            },
            simpleData: {
                enable: true
            }
        },
        callback: {
            beforeDrag: beforeDrag,
//                beforeRemove: beforeRemove,
//          beforeRename: beforeRename,
//                onRemove: onRemove,
            onClick: zTreeOnClick
        }
    };
    var settingGroup = {
        view: {
            selectedMulti: false
        },
        edit: {
            enable: false
        },
        data: {
            keep: {
                parent: true,
                leaf: true
            },
            simpleData: {
                enable: true
            }
        }
    };
    var log, className = "dark";
    function beforeDrag(treeId, treeNodes) {
        return false;
    }
    //选中赋值到input中
    function zTreeOnClick(event, treeId, treeNode) {
        $(".group-picker").val(treeNode.name);
        $("#scale_type").val(treeNode.scale_type);
        $("#scale_id").val(treeNode.id);
    }
    $(document).ready(function () {
        onLoadZTree();
    });
    function onLoadZTree() {
        var treeNodes;
        $.ajax({
            url: $(".group-picker").attr('url'),
            type: 'get',
            async: false,
            dataType: 'json',
            success: function (data) {
                //请求成功后处理函数
                treeNodes = data.data_list.aGroup;//把后台封装好的简单Json格式赋给treeNodes
                var t = $("#treeDemo");
                $.fn.zTree.init(t, setting, treeNodes);
                $('#treeDemoinput').on('input', function(){
                    // 过滤数组
                    var _filterList = getCurIndex(treeNodes, 'name', $(this).val())
                    $.fn.zTree.init(t, setting, _filterList);
                })
            }
        });
        
    }


    $("form").submit(function (e) {
        //alert("Submitted");
    });
    var settingTmk = {
        view: {
            selectedMulti: false
        },
        edit: {
            enable: false
        },
        data: {
            keep: {
                parent: true,
                leaf: true
            },
            simpleData: {
                enable: true
            }
        }
    };
    var zNodesTmk = getTmkListData();
    $.each(zNodesTmk, function (i, item) {
//            item.isParent = true;
        item.name = item.full_name
//            item.Pid = item.id
    })
    $.fn.zTree.init($("#tmklist"), settingTmk, zNodesTmk);
    $('#tmklistinput').on('input', function(){
        // 过滤数组
        var _filterList = getCurIndex(zNodesTmk, 'name', $(this).val())
        $.fn.zTree.init($("#tmklist"), settingTmk, _filterList);
    })
    var settingCc = {
        view: {
            selectedMulti: false
        },
        edit: {
            enable: false
        },
        data: {
            keep: {
                parent: true,
                leaf: true
            },
            simpleData: {
                enable: true
            }
        }
    };
    var zNodesCc = getCcListData();
    $.each(zNodesCc, function (i, item) {
//            item.isParent = true;
        item.name = item.full_name
    })
    $.fn.zTree.init($("#cclist"), settingCc, zNodesCc);
    
    $('#cclistinput').on('input', function(){
        // 过滤数组
        var _filterList = getCurIndex(zNodesCc, 'name', $(this).val())
        $.fn.zTree.init($("#cclist"), settingCc, _filterList);
    })

    $('.stu_export').click(function () {
	var aIds=[];
        $("input[name='ck']:checked").each(function () {
            aIds.push($(this).val());
        });
        if (aIds == '' || aIds.length == 0) {
            layer.alert("至少选择一项");
        } else {
            var url = $("input[name='stuExport']").val();
            $.ajax({
                url: url,
                type: 'post',
                dataType: 'json',
                data: {ids: aIds},
                success: function (resp) {
                    if (resp.success == 1) {
                        window.open(resp.data);
                    } else {
                        layer.alert("导出失败");
                    }
                },
                complete: function () {
                },
                error: function () {

                }
            });
        }

    });



    $('.test_stu_export').click(function () {

        var formData = $("form").serializeArray();
        var url = $("input[name='stuExport']").val();
            $.ajax({
                url: url,
                type: 'post',
                dataType: 'json',
                data: formData,
                success: function (resp) {
                    if (resp.success == 1) {
                        window.open(resp.data);
                    } else {
                        layer.alert("导出失败");
                    }
                },
                complete: function () {
                },
                error: function () {

                }
            });

    });

    $(function () {
        $(".daoru").click(function () {
            var url = $("input[name='stuImport']").val();
            var formdata = new FormData();
            formdata.append("stu_import", $('input[name=stu_import]')[0].files[0]);
            $.ajax({
                type: "POST",
                url: url,
                data: formdata,
                processData: false,
                contentType: false,
                dataType: "json",
                success: function (resp) {
                    if (resp.success == 1) {
                        var tipstr = '<ul><li>总数:' + resp.num.total + ',</li><li>成功:' + resp.num.success + ',</li><li>失败：' + resp.num.failed + ',</li><li>激活' + resp.num.active + ",</li><li><a href='/ajax/student/student/exportReppeatStu'>导出重复数据</a></li><ul>";

                        layer.open({
                          type: 1,
                          title: false,
                          closeBtn: 0,
                          shadeClose: true,
                          area: ['200px', '120px'],
                          skin: 'yourclass',
                          content: tipstr
                        });
                    } else {
                        alert(resp.msg);
                        window.location.reload();
                    }
                },
            });
        })
    })

    //导出重复数据
    /*var exportRepeat = function(formdata){
        $.ajax({
            type: "POST",
            url: '/ajax/student/student/exportReppeatStu',
            data: formdata,
            processData: false,
            contentType: false,
            dataType: "json",
            success: function (resp) {
                if (resp.success == 1) {
                    window.open(resp.data);
                    window.location.reload();
                } else {
                    layer.alert("导出失败");
                }
            },
        });
    }*/

    function getDates(sDateType) {
        var aDate = new Array();
        aDate['sStartDate'] = '';
        aDate['sEndDate'] = '';
        switch (sDateType) {
            case 'month':
                aDate['sStartDate'] = '<?php $BeginDate = date("Y-m-01", strtotime(date("Y-m-d"))); xcho($BeginDate)?>';
                aDate['sEndDate'] = '<?php xcho(date("Y-m-d", strtotime("$BeginDate +1 month -1 day")))?>';
                break;
            case 'sevenday':
                aDate['sStartDate'] = '<?php xcho(date("Y-m-d", strtotime("-7 days")))?>';
                aDate['sEndDate'] = '<?php xcho(date("Y-m-d", strtotime("-1 days")))?>';
                break;
            case 'thirtyday':
                aDate['sStartDate'] = '<?php xcho(date("Y-m-d", strtotime("-30 days")))?>';
                aDate['sEndDate'] = '<?php xcho(date("Y-m-d", strtotime("-1 days")))?>';
                break;
            case 'today':
                aDate['sStartDate'] = '<?php xcho(date("Y-m-d"))?>';
                aDate['sEndDate'] = '<?php xcho(date("Y-m-d"))?>';
                break;
            case 'week':
                aDate['sStartDate'] = '<?php xcho(date("Y-m-d", strtotime("this week")))?>';
                aDate['sEndDate'] = '<?php xcho(date("Y-m-d", strtotime("this week +6 day")))?>';
                break;
            case 'yesterday':
                aDate['sStartDate'] = '<?php xcho(date("Y-m-d", strtotime("-1 days")))?>';
                aDate['sEndDate'] = '<?php xcho(date("Y-m-d", strtotime("-1 days")))?>';
                break;
            default:

                break;
        }
        return aDate;
    }

</script>
<?php include_once TPL_PATH . 'public/foot_script.phtml'; ?>

<button id="top" style="height: 50px;width: 50px;"></button></body>
</html>
